import os
import shutil
import time
from datetime import datetime
from pathlib import Path

import pytest

from commons import settings
from commons.case import TestApi

# TestApi.find_yaml_case(Path('testcases'))  # 加载yaml文件
TestApi.find_yaml_case()  # 加载yaml文件

if __name__ == '__main__':
    # 启动框架
    now = datetime.now().strftime("%Y%m%d_%H%M%S")
    pytest.main([__file__, '-c', settings.pytest_ini_path])
    time.sleep(3)
    os.system("allure generate ./temps -o ./reports --clean")

    # 备份日志文件
    shutil.move('logs/pytest.log', 'logs/pytest_{}.log'.format(now))
